/**
 * 通用自定义错误
 */
const ErrorCommon = class ErrorCommon extends Error {
	constructor(code, message) {
		super(message);
		this.code = code;
	}
}

/**
 * 语音合成自定义错误
 */
const ErrorText2audio = class ErrorText2audio extends Error {
	constructor(code, message, consume) {
		super(message);
		this.code = code;
		this.consume = consume;
	}
}

/**
 * 四舍五入，保留位数为roundDigit
 * @param {Object} numberRound	
 * @param {Object} roundDigit	小数位数
 */
const roundFun = function(numberRound, roundDigit) {
	if (numberRound >= 0) {
		var tempNumber = parseInt((numberRound * Math.pow(10, roundDigit) + 0.5)) / Math.pow(10, roundDigit);
		return tempNumber;
	} else {
		numberRound1 = -numberRound;
		var tempNumber = parseInt((numberRound1 * Math.pow(10, roundDigit) + 0.5)) / Math.pow(10, roundDigit);
		return -tempNumber;
	}
}

module.exports = {
	ErrorCommon,
	ErrorText2audio,
	roundFun
}